package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 数据字典-销售机会输单原因
 *
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/26 10:19
 * @since v1.0
 */
@Getter
public enum OpportunityLossCauseEnum {

    // 销售机会输单原因
    COMPETITOR_WIN("1", "enum.opportunityLossCause.name.competitor_win", "competitorWin"),


    TOO_HIGH_PRICE("2", "enum.opportunityLossCause.name.too_high_price", "tooHighPrice"),


    DECISION_MAKER_NOT_SUPPORT("3", "enum.opportunityLossCause.name.decision_maker_not_support", "decisionMakerNotSupport"),


    NOT_MATCH_BUSINESS("4", "enum.opportunityLossCause.name.not_match_business", "notMatchBusiness"),


    OTHER("5", "enum.opportunityLossCause.name.other", "other"),
    ;

    private String code;
    private String name;
    private String attr;

    OpportunityLossCauseEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static OpportunityLossCauseEnum getByCode(String code){
        for (OpportunityLossCauseEnum value : values()) {
            if (Objects.equals(value.getCode(),code)) {
                return value;
            }
        }
        return null;
    }
}
